﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace syh876.com.ajax.Account
{
    /// <summary>
    /// CheckCode 的摘要说明
    /// </summary>
    public class CheckCode : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string txtcheckcode = Common.RequestHelper.GetString("txtCheckCode").Trim();

            if (!string.IsNullOrEmpty(txtcheckcode))
            {
                if (HttpContext.Current.Session["CheckCode"] != null)
                {
                    string str = HttpContext.Current.Session["CheckCode"].ToString();
                    if (String.Equals(HttpContext.Current.Session["CheckCode"].ToString().ToLower(), txtcheckcode.ToLower()))
                    {
                        context.Response.Write("true");
                    }
                }
                else
                {
                    context.Response.Write("验证码不正确！");
                }
            }
            else
            {
                context.Response.Write("验证码不能为空");
            }

            //string email = Common.RequestHelper.GetString("email");
            //string sjcode = System.Guid.NewGuid().ToString().Replace("-", "").Remove(6);
            //string MD5code = Common.MD5.Md5En(sjcode);
            //Common.CookieHelper.AddCookies("CheckCode", sjcode);
            //if (!Common.PageValidate.IsEmail(email))
            //{
            //    context.Response.Write("0");
            //}
            //else
            //{
            //    Common.EmailHelper.SendEmail(email, "[生意汇]您正在进行绑定邮箱操作", "验证码：" + sjcode, "生意汇");

            //    context.Response.Write("1");
            //}
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}